Tau-U power analysis

Author

Jürgen Wilbert

Published

July 30, 2023

Research question

Q: How strong does a data trend influence the effect-size estimation and power of various tau-u analyzing methods?

Length of A and B phase

Code
design <- design_template(
  n = n_sims,
  start_value = 50,
  s = 10,
  level = 1 * statistic,
  trend = rnorm(n_sims, 0, abs(0.1 / (A_length + B_length))),
  slope = rnorm(n_sims, 0, abs(0.1 / B_length)),
  phase_design = list(A = A_length, B = B_length),
  distribution = "gaussian"
)

iterations <- iterations_template(
  A_length = c(3, 5, 7, 9, 11, 13, 15, 17, 19),
  B_length = c(5, 7, 10, 15, 25, 50),
  statistic = c(0, 1),
  n_sims = 5000
)

out <- create_mc("phaselength.rds", 
                 design, iterations, 
                 force_renew = FALSE)
Code
ex_design <- design(
  n = 3,
  start_value = 50,
  s = 10,
  level = 1,
  trend = rnorm(3, 0, abs(0.1 / c(8, 26, 69))),
  slope = rnorm(3, 0, abs(0.1 / c(5, 15, 50))),
  phase_design = list(A = c(3,11,19), B = c(5,15,50)),
  distribution = "gaussian"
)

ex <- random_scdf(ex_design,seed = 124)

ex_fn <- function(x) {
  scplot(x) %>% 
    set_yaxis(limits = c(40,70)) %>%
    add_theme("basic")
}


ex_fn(ex[1])

Code
ex_fn(ex[2])

Code
ex_fn(ex[3])

Code
mcplot(out, template = "power")

Code
ggsave(filename = "figure-phaselength.png", width = 18, height = 18,  device='png', units = "cm", dpi=300, scale = 1)
Code
mctable(out, wider = "statistic", format = "html", digits = 0)
statistic 0
statistic 1
A_length B_length Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted
3 5 2 1 3 2 51 28 35 51
5 5 3 1 2 3 79 48 48 78
7 5 3 2 3 4 84 55 54 83
9 5 2 2 3 4 85 58 58 84
11 5 3 3 3 4 90 59 58 89
13 5 3 2 2 4 91 56 56 90
15 5 3 2 2 4 93 54 53 92
17 5 3 2 3 4 93 53 53 92
19 5 3 3 3 4 94 51 51 93
3 7 2 1 3 2 60 25 31 60
5 7 3 2 3 3 83 62 53 83
7 7 3 2 3 5 91 75 69 90
9 7 2 2 3 4 93 77 76 91
11 7 3 3 3 5 95 80 77 94
13 7 3 2 2 5 96 80 77 95
15 7 3 3 3 5 97 79 76 96
17 7 3 2 3 5 98 75 76 96
19 7 3 3 3 5 98 76 76 97
3 10 3 0 3 3 72 6 29 72
5 10 3 1 3 3 86 67 57 86
7 10 2 1 3 4 94 83 77 93
9 10 3 2 3 5 96 89 84 94
11 10 3 2 3 5 98 93 89 96
13 10 3 3 4 5 99 93 91 97
15 10 3 2 3 5 99 94 93 98
17 10 3 2 2 5 99 94 92 98
19 10 3 3 3 5 100 94 92 98
3 15 2 0 3 2 76 0 28 76
5 15 3 1 3 3 93 67 55 93
7 15 3 1 3 5 97 89 76 96
9 15 3 1 4 5 99 95 89 97
11 15 3 2 4 5 100 98 94 98
13 15 4 2 4 5 100 99 97 98
15 15 3 2 3 5 100 99 97 98
17 15 3 2 3 5 100 99 98 98
19 15 3 2 3 6 100 100 99 99
3 25 3 0 4 3 83 0 24 83
5 25 3 0 3 4 95 47 47 94
7 25 3 0 4 4 99 88 71 97
9 25 4 1 4 6 100 97 86 97
11 25 3 1 4 5 100 99 94 98
13 25 3 1 4 5 100 100 97 98
15 25 4 2 4 6 100 100 99 98
17 25 4 2 5 6 100 100 99 97
19 25 3 2 4 6 100 100 100 98
3 50 3 0 4 3 86 0 17 86
5 50 3 0 5 4 97 0 34 97
7 50 2 0 4 4 100 66 52 98
9 50 3 0 4 5 100 93 70 98
11 50 3 0 4 5 100 99 83 98
13 50 4 0 5 6 100 100 92 98
15 50 4 1 5 6 100 100 96 98
17 50 4 1 5 6 100 100 98 98
19 50 4 1 5 7 100 100 99 98
Code
mcplot(out,var_y = "es")

Code
ggsave(filename = "figure-phaselength-tau.png", width = 18, height = 18,  device='png', units = "cm", dpi=300, scale = 1)
Code
mctable(out, wider = "statistic", format = "html", var_y = "es")
statistic 0
statistic 1
A_length B_length Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted
3 5 0.00 0.00 0.00 0.00 0.84 0.84 0.45 0.61
5 5 0.00 0.00 0.00 0.00 0.84 0.85 0.47 0.62
7 5 0.00 0.00 0.00 -0.01 0.84 0.85 0.45 0.61
9 5 0.00 0.00 0.00 0.00 0.84 0.84 0.42 0.58
11 5 0.00 0.01 0.00 0.00 0.84 0.84 0.38 0.56
13 5 0.00 0.00 0.00 0.00 0.84 0.84 0.36 0.54
15 5 0.00 0.00 0.00 0.00 0.84 0.84 0.33 0.53
17 5 0.00 0.00 0.00 0.00 0.84 0.84 0.31 0.50
19 5 0.00 0.00 0.00 0.00 0.84 0.84 0.29 0.49
3 7 0.00 0.00 0.00 0.00 0.84 0.84 0.40 0.58
5 7 0.01 0.00 0.01 0.00 0.84 0.84 0.44 0.60
7 7 0.00 0.00 0.00 0.00 0.84 0.84 0.45 0.61
9 7 0.00 0.00 0.00 0.00 0.84 0.85 0.44 0.60
11 7 0.00 0.00 0.00 0.00 0.84 0.84 0.42 0.59
13 7 0.00 -0.01 0.00 0.00 0.84 0.84 0.40 0.58
15 7 0.00 0.00 0.00 0.00 0.84 0.84 0.38 0.56
17 7 0.01 0.00 0.00 0.00 0.84 0.84 0.36 0.55
19 7 0.00 0.00 0.00 0.00 0.84 0.84 0.34 0.54
3 10 0.00 0.00 0.00 0.00 0.84 0.84 0.33 0.52
5 10 0.00 0.00 0.00 0.00 0.84 0.84 0.40 0.57
7 10 0.00 0.00 0.00 0.00 0.84 0.84 0.43 0.59
9 10 0.01 0.01 0.01 0.01 0.84 0.84 0.44 0.59
11 10 0.00 0.00 0.00 0.00 0.84 0.84 0.44 0.60
13 10 0.00 0.00 0.00 0.00 0.84 0.84 0.43 0.59
15 10 0.00 0.01 0.00 0.00 0.84 0.84 0.42 0.59
17 10 0.00 0.00 0.00 0.00 0.84 0.84 0.41 0.58
19 10 0.00 0.00 0.00 0.00 0.84 0.84 0.39 0.57
3 15 0.01 0.01 0.00 0.00 0.84 0.84 0.25 0.46
5 15 0.00 0.00 0.00 0.00 0.84 0.84 0.33 0.52
7 15 0.00 0.00 0.00 0.00 0.84 0.84 0.38 0.56
9 15 0.00 0.00 0.00 0.00 0.84 0.84 0.41 0.57
11 15 0.00 0.00 0.00 0.00 0.84 0.84 0.43 0.59
13 15 0.00 0.00 0.00 0.00 0.84 0.84 0.43 0.59
15 15 0.00 0.00 0.00 0.00 0.84 0.84 0.43 0.59
17 15 0.00 0.00 0.00 0.00 0.84 0.84 0.43 0.59
19 15 0.00 0.00 0.00 0.00 0.84 0.84 0.43 0.59
3 25 0.00 0.00 0.00 0.00 0.84 0.84 0.17 0.37
5 25 0.00 0.00 0.00 0.00 0.84 0.84 0.24 0.44
7 25 0.00 0.00 0.00 0.00 0.84 0.84 0.30 0.49
9 25 0.00 0.00 0.00 0.00 0.84 0.84 0.34 0.52
11 25 0.01 0.01 0.00 0.01 0.84 0.84 0.37 0.54
13 25 -0.01 -0.01 0.00 0.00 0.84 0.84 0.39 0.56
15 25 0.00 0.00 0.00 0.00 0.84 0.84 0.40 0.57
17 25 0.00 0.00 0.00 0.00 0.84 0.84 0.41 0.57
19 25 -0.01 -0.01 0.00 0.00 0.84 0.84 0.42 0.58
3 50 0.00 0.00 0.00 0.00 0.84 0.84 0.09 0.28
5 50 0.00 0.00 0.00 0.00 0.84 0.84 0.14 0.34
7 50 -0.01 -0.01 0.00 0.00 0.84 0.84 0.18 0.38
9 50 0.00 0.00 0.00 0.00 0.84 0.84 0.22 0.41
11 50 0.00 0.00 0.00 0.00 0.84 0.84 0.25 0.45
13 50 0.00 0.00 0.00 0.00 0.84 0.84 0.28 0.47
15 50 0.00 0.00 0.00 0.00 0.84 0.84 0.30 0.49
17 50 0.00 0.00 0.00 0.00 0.84 0.84 0.32 0.51
19 50 0.00 0.00 0.00 0.00 0.84 0.84 0.34 0.52

Intervention strength

Code
design <- design_template(
    n = n_sims,
    start_value = 50,
    s = 10,
    level = level_effect * statistic,
    trend = rnorm(n_sims, 0, 0.1 / length),
    slope = rnorm(n_sims, 0, 0.1 / (length * 2/3)),
    phase_design = list(A = length * 1/3, B = length * 2/3),
    distribution = "gaussian"
)

iterations <- iterations_template(
  level_effect = c(0.25, 0.5, 0.75, 1, 1.25, 1.5),
  length = c(9, 12, 15, 21, 27, 33, 39, 45),
  statistic = c(0,1),
  n_sims = 5000
)

out <- create_mc("interventioneffect-length.rds", 
                 design, iterations,
                 force_renew = FALSE)
Code
ex_design <- design(
  n = 3,
  start_value = 50,
  s = 10,
  level = c(0.25, 1, 1.5),
  trend = rnorm(3, 0, abs(0.1 / c(9, 21, 50))),
  slope = rnorm(3, 0, abs(0.1 / c(6, 14, 45))),
  phase_design = list(A = c(3,7,15), B = c(6,14,45)),
  distribution = "gaussian"
)

ex <- random_scdf(ex_design,seed = 124)

ex_fn <- function(x) {
  scplot(x) %>% 
    set_yaxis(limits = c(40,80)) %>%
    add_theme("basic")
}


ex_fn(ex[1])

Code
ex_fn(ex[2])

Code
ex_fn(ex[3])

Code
mcplot(out, var_x = 2, var_shape = 1, template = "power")

Code
ggsave(filename = "figure-interventioneffect.png", width = 18, height = 18,  device='png', units = "cm", dpi=300, scale = 1)
Code
mctable(out, wider = "statistic", format = "html", digits = 0)
statistic 0
statistic 1
level_effect length Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted
0 9 3 1 2 3 9 3 7 9
0 9 3 1 2 3 21 8 13 21
1 9 3 1 3 3 43 17 22 43
1 9 2 1 2 2 63 26 30 63
1 9 2 1 2 2 81 36 37 81
2 9 2 1 3 2 92 42 40 92
0 12 3 1 3 6 10 3 8 14
0 12 3 1 2 6 31 11 18 33
1 12 3 1 3 6 56 25 31 56
1 12 3 1 3 7 80 44 45 78
1 12 3 1 3 7 93 60 53 89
2 12 3 1 3 7 98 72 58 94
0 15 3 1 3 3 11 6 10 12
0 15 2 1 3 3 34 19 23 34
1 15 2 1 3 3 63 42 40 63
1 15 2 1 3 3 87 68 57 86
1 15 2 1 3 3 97 86 69 96
2 15 3 1 3 3 100 96 75 99
0 21 3 1 3 4 17 9 14 18
0 21 3 1 3 4 50 31 34 50
1 21 3 1 3 4 81 63 57 80
1 21 2 1 3 4 97 89 77 95
1 21 3 1 3 4 100 98 87 98
2 21 3 1 3 4 100 100 92 99
0 27 3 1 3 6 21 10 16 22
0 27 2 1 4 5 60 40 42 60
1 27 3 1 4 5 91 77 71 89
1 27 3 1 3 5 99 96 88 97
1 27 3 1 4 6 100 100 95 98
2 27 3 1 4 5 100 100 98 98
0 33 3 1 4 5 25 13 19 26
0 33 3 1 4 5 69 51 50 68
1 33 3 1 3 5 96 88 79 94
1 33 3 1 4 5 100 99 94 97
1 33 3 1 3 5 100 100 98 98
2 33 3 1 3 5 100 100 100 98
0 39 3 1 4 5 31 17 23 32
0 39 4 1 4 6 77 59 58 76
1 39 4 1 4 6 98 92 86 96
1 39 4 1 4 6 100 100 97 98
1 39 3 1 4 5 100 100 100 98
2 39 3 1 3 5 100 100 100 98
0 45 3 1 4 5 34 20 25 34
0 45 3 1 4 5 83 68 63 82
1 45 3 1 4 5 99 96 90 97
1 45 4 2 4 6 100 100 99 98
1 45 4 2 4 6 100 100 100 98
2 45 3 1 4 5 100 100 100 98
Code
mcplot(out, var_y = "es", var_x = 2, var_shape = 1)

Code
ggsave(filename = "figure-interventioneffect-tau.png", width = 18, height = 18,  device='png', units = "cm", dpi=300, scale = 1)
Code
mctable(out, var_y = "es", wider = "statistic", format = "html")
statistic 0
statistic 1
level_effect length Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted
0.25 9 0.00 0.00 0.00 0.00 0.28 0.28 0.14 0.20
0.50 9 0.00 0.00 0.00 0.00 0.52 0.52 0.26 0.37
0.75 9 0.01 0.01 0.00 0.01 0.71 0.71 0.36 0.50
1.00 9 0.00 0.00 0.00 0.00 0.84 0.84 0.42 0.59
1.25 9 0.00 -0.01 -0.01 0.00 0.92 0.92 0.46 0.65
1.50 9 -0.01 0.00 0.00 0.00 0.97 0.96 0.48 0.68
0.25 12 0.00 0.00 0.00 0.00 0.27 0.27 0.13 0.18
0.50 12 -0.01 -0.01 -0.01 -0.01 0.52 0.53 0.25 0.35
0.75 12 -0.01 -0.01 0.00 0.00 0.71 0.71 0.35 0.47
1.00 12 -0.01 -0.01 0.00 0.00 0.84 0.84 0.41 0.55
1.25 12 -0.01 -0.01 0.00 0.00 0.92 0.92 0.45 0.60
1.50 12 -0.01 -0.01 0.00 0.00 0.96 0.96 0.47 0.64
0.25 15 0.01 0.01 0.01 0.00 0.27 0.27 0.13 0.19
0.50 15 0.00 0.00 0.00 0.00 0.52 0.52 0.25 0.35
0.75 15 0.00 0.00 0.00 0.00 0.71 0.71 0.34 0.48
1.00 15 -0.01 -0.01 -0.01 0.00 0.84 0.84 0.40 0.57
1.25 15 0.00 0.00 0.00 0.00 0.92 0.92 0.44 0.63
1.50 15 0.01 0.01 0.00 0.01 0.97 0.97 0.46 0.66
0.25 21 0.00 0.00 0.00 0.00 0.28 0.28 0.13 0.18
0.50 21 0.01 0.01 0.00 0.00 0.52 0.52 0.24 0.35
0.75 21 0.00 0.00 0.00 -0.01 0.70 0.70 0.33 0.47
1.00 21 0.00 0.00 0.00 0.00 0.84 0.84 0.39 0.56
1.25 21 0.00 0.00 0.00 0.00 0.92 0.92 0.43 0.62
1.50 21 0.00 -0.01 0.00 0.00 0.96 0.97 0.45 0.65
0.25 27 0.01 0.00 0.00 0.00 0.27 0.27 0.13 0.18
0.50 27 -0.01 -0.01 0.00 0.00 0.52 0.52 0.24 0.34
0.75 27 0.00 0.00 0.00 0.00 0.71 0.71 0.33 0.46
1.00 27 0.00 0.00 0.00 0.00 0.84 0.84 0.39 0.55
1.25 27 0.00 0.00 0.00 0.00 0.92 0.92 0.43 0.61
1.50 27 0.00 0.00 0.00 0.00 0.97 0.97 0.45 0.64
0.25 33 0.00 0.00 0.00 0.00 0.28 0.28 0.13 0.18
0.50 33 0.00 0.00 0.00 0.00 0.51 0.51 0.24 0.34
0.75 33 0.00 0.00 0.00 0.00 0.71 0.71 0.32 0.46
1.00 33 0.00 0.00 0.00 0.00 0.84 0.84 0.38 0.55
1.25 33 0.00 0.00 0.00 0.00 0.92 0.92 0.42 0.61
1.50 33 0.00 0.00 0.00 0.00 0.97 0.97 0.44 0.64
0.25 39 0.00 0.00 0.00 0.00 0.28 0.28 0.13 0.18
0.50 39 0.00 0.00 0.00 0.00 0.52 0.52 0.24 0.34
0.75 39 0.00 0.00 0.00 0.00 0.71 0.71 0.32 0.47
1.00 39 0.00 0.00 0.00 0.00 0.84 0.84 0.38 0.55
1.25 39 0.00 0.00 0.00 0.00 0.92 0.92 0.42 0.61
1.50 39 0.00 0.00 0.00 0.00 0.97 0.97 0.44 0.64
0.25 45 0.00 0.00 0.00 0.00 0.28 0.28 0.13 0.18
0.50 45 0.00 0.00 0.00 0.00 0.52 0.52 0.24 0.34
0.75 45 -0.01 -0.01 0.00 0.00 0.71 0.71 0.32 0.46
1.00 45 0.00 0.00 0.00 0.00 0.84 0.84 0.38 0.55
1.25 45 0.00 0.00 0.00 0.00 0.92 0.92 0.42 0.61
1.50 45 0.00 0.00 0.00 0.00 0.96 0.97 0.44 0.64

Strength of trend effect and level-effect

Code
design <- design_template(
    n = n_sims,
    start_value = 50,
    s = 10,
    level = level_effect * statistic,
    trend = trend_effect / length,
    slope = rnorm(n_sims, 0, abs(0.1/ (length* 2/3))),
    phase_design = list(A = length * 1/3, B = length * 2/3 ),
    distribution = "gaussian"
)

iterations <- iterations_template(
  trend_effect = c(-0.5, -0.25, 0, +0.25, +0.5),
  level_effect = c(0.25, 0.5, 0.75, 1, 1.25, 1.5),
  statistic = c(0, 1),
  length = 15,
  n_sims = 5000
)

out <- create_mc("trend-level.rds", 
                 design, iterations,
                 force_renew = FALSE)
Code
ex_design <- design(
  n = 3,
  start_value = 50,
  s = 10,
  level = c(0.25, 0.5, 1),
  trend = c(-0.5/15, 0, 0.5/15),
  slope = rnorm(3, 0, abs(0.1 / 10)),
  phase_design = list(A = 5, B = 10),
  distribution = "gaussian"
)

ex <- random_scdf(ex_design,seed = 124)

ex_fn <- function(x) {
  scplot(x) %>% 
    set_yaxis(limits = c(40, 80)) %>%
    add_theme("basic")
}


ex_fn(ex[1])

Code
ex_fn(ex[2])

Code
ex_fn(ex[3])

Code
mcplot(out, var_y = "p", var_x = 1, var_shape = 2, template = "power")

Code
ggsave(filename = "figure-trend-level.png", width = 18, height = 18,  device='png', units = "cm", dpi=300, scale = 1.1)
Code
mctable(out, wider = "statistic", format = "html", digits = 0)
statistic 0
statistic 1
trend_effect level_effect Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted
0 0 0 0 0 1 2 1 1 3
0 0 1 0 1 2 5 3 4 6
0 0 2 1 3 3 11 5 9 12
0 0 6 2 7 6 21 10 18 21
0 0 11 5 14 11 32 17 32 32
0 0 0 0 0 1 11 6 5 12
0 0 1 0 1 2 21 12 12 21
0 0 3 1 3 3 33 18 22 33
0 0 5 2 6 6 49 29 37 49
0 0 11 4 14 11 64 39 53 63
0 1 0 0 0 1 32 19 14 33
0 1 1 0 1 2 48 31 26 48
0 1 2 1 3 3 65 45 42 65
0 1 6 3 7 6 77 53 55 76
0 1 10 4 14 11 87 65 71 86
0 1 0 0 0 1 63 44 28 64
0 1 1 0 1 2 77 58 42 77
0 1 2 1 2 3 88 69 56 87
0 1 5 2 6 6 93 77 70 93
0 1 10 4 14 11 97 85 81 96
0 1 0 0 0 1 87 72 41 87
0 1 1 0 1 2 94 81 55 93
0 1 2 1 2 3 97 88 68 96
0 1 5 2 6 6 99 91 79 98
0 1 10 5 13 10 100 94 86 98
0 2 0 0 0 1 97 88 53 97
0 2 1 0 1 2 99 92 65 98
0 2 2 1 3 3 100 96 75 99
0 2 5 2 7 6 100 97 82 99
0 2 10 5 14 11 100 98 87 99
Code
mcplot(out, var_y = "es", var_x = 1, var_shape = 2)

Code
ggsave(filename = "figure-trend-level-tau.png", width = 18, height = 18,  device='png', units = "cm", dpi=300, scale = 1.1)
Code
mctable(out, var_y = "es", wider = "statistic", format = "html")
statistic 0
statistic 1
trend_effect level_effect Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted
-0.50 0.25 -0.27 -0.26 -0.18 -0.18 0.00 0.02 -0.05 0.01
-0.25 0.25 -0.15 -0.14 -0.10 -0.10 0.14 0.15 0.04 0.10
0.00 0.25 0.00 0.00 0.00 0.00 0.27 0.27 0.13 0.19
0.25 0.25 0.14 0.14 0.09 0.10 0.41 0.40 0.22 0.27
0.50 0.25 0.27 0.26 0.18 0.18 0.51 0.49 0.29 0.34
-0.50 0.50 -0.27 -0.26 -0.18 -0.18 0.28 0.29 0.08 0.19
-0.25 0.50 -0.14 -0.13 -0.09 -0.09 0.40 0.40 0.16 0.27
0.00 0.50 0.01 0.01 0.00 0.01 0.52 0.52 0.25 0.35
0.25 0.50 0.14 0.13 0.09 0.09 0.62 0.61 0.32 0.42
0.50 0.50 0.27 0.26 0.18 0.18 0.70 0.69 0.39 0.47
-0.50 0.75 -0.28 -0.26 -0.18 -0.18 0.51 0.52 0.19 0.35
-0.25 0.75 -0.14 -0.13 -0.09 -0.09 0.62 0.63 0.27 0.42
0.00 0.75 0.00 0.00 0.00 0.00 0.71 0.72 0.34 0.49
0.25 0.75 0.14 0.14 0.10 0.10 0.78 0.77 0.39 0.53
0.50 0.75 0.27 0.26 0.18 0.18 0.84 0.82 0.45 0.57
-0.50 1.00 -0.28 -0.26 -0.18 -0.19 0.71 0.72 0.29 0.48
-0.25 1.00 -0.14 -0.14 -0.09 -0.09 0.78 0.79 0.35 0.53
0.00 1.00 0.00 0.00 0.00 0.00 0.85 0.84 0.40 0.58
0.25 1.00 0.14 0.13 0.09 0.09 0.89 0.88 0.45 0.60
0.50 1.00 0.27 0.25 0.18 0.18 0.92 0.90 0.49 0.62
-0.50 1.25 -0.26 -0.25 -0.18 -0.17 0.84 0.86 0.35 0.58
-0.25 1.25 -0.13 -0.13 -0.09 -0.09 0.89 0.90 0.39 0.61
0.00 1.25 0.00 0.00 0.00 0.00 0.92 0.92 0.44 0.63
0.25 1.25 0.14 0.13 0.09 0.10 0.95 0.94 0.48 0.65
0.50 1.25 0.27 0.25 0.18 0.18 0.96 0.95 0.51 0.66
-0.50 1.50 -0.27 -0.26 -0.18 -0.18 0.92 0.93 0.39 0.63
-0.25 1.50 -0.13 -0.12 -0.09 -0.09 0.95 0.95 0.43 0.65
0.00 1.50 -0.01 -0.01 -0.01 -0.01 0.97 0.96 0.46 0.66
0.25 1.50 0.14 0.13 0.09 0.09 0.98 0.97 0.49 0.67
0.50 1.50 0.27 0.26 0.18 0.18 0.98 0.97 0.52 0.67

Strength of trend effect and meassurement times

Code
design <- design_template(
    n = n_sims,
    start_value = 50,
    s = 10,
    level = level_effect * statistic,
    trend = trend_effect / length,
    slope = rnorm(n_sims, 0, 0.1 / (length * 2/3)),
    phase_design = list(A = length * 1/3, B = length * 2/3),
    distribution = "gaussian"
)

iterations <- list(
  trend_effect = c(-0.5, -0.25, 0, +0.25, +0.5),
  length = c(9, 12, 15, 21, 27, 33),
  statistic = c(0,1),
  level_effect = 1,
  n_sims = 5000
)

out <- create_mc("trend-length.rds", 
                 design, iterations,
                 force_renew = FALSE)
Code
ex_design <- design(
  n = 3,
  start_value = 50,
  s = 10,
  level = 1,
  trend = c(-0.5/9, 0, 0.5/27),
  slope = rnorm(3, 0, abs(0.1 / c(6,10,28))),
  phase_design = list(A = c(3,5,9), B = c(6,10,18)),
  distribution = "gaussian"
)

ex <- random_scdf(ex_design,seed = 124)

ex_fn <- function(x) {
  scplot(x) %>% 
    set_yaxis(limits = c(40, 80)) %>%
    add_theme("basic")
}


ex_fn(ex[1])

Code
ex_fn(ex[2])

Code
ex_fn(ex[3])

Code
mcplot(out, var_x = 1, var_shape = 2, template = "power")

Code
ggsave(filename = "figure-trend-length.png", width = 18, height = 18,  device='png', units = "cm", dpi=300, scale = 1.1)
Code
mctable(out, var_y = "p", wider = "statistic", format = "html", digits = 0)
statistic 0
statistic 1
trend_effect length Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted
0 9 1 0 1 1 40 17 14 40
0 9 1 1 1 1 53 23 21 53
0 9 2 1 2 2 62 26 29 62
0 9 5 1 5 5 72 29 40 72
0 9 8 3 9 8 80 31 48 80
0 12 0 0 0 5 55 26 21 56
0 12 1 0 1 5 67 35 30 67
0 12 2 0 2 6 79 43 42 77
0 12 5 1 5 8 87 50 56 84
0 12 10 3 11 12 92 54 66 88
0 15 0 0 0 1 62 43 28 62
0 15 1 0 1 2 76 57 41 76
0 15 2 1 3 3 88 70 59 88
0 15 5 2 7 6 94 79 71 94
0 15 11 5 15 11 96 83 81 95
0 21 0 0 0 2 81 66 41 81
0 21 1 0 0 3 92 81 62 91
0 21 2 1 3 4 97 88 78 95
0 21 7 3 9 8 99 95 89 97
0 21 16 7 21 16 100 98 95 98
0 27 0 0 0 4 91 79 54 90
0 27 0 0 1 3 97 91 74 96
0 27 3 1 3 5 99 96 89 97
0 27 8 3 11 9 100 99 96 97
0 27 19 8 25 19 100 100 99 96
0 33 0 0 0 4 96 90 64 95
0 33 0 0 1 3 99 97 84 98
0 33 3 1 3 5 100 99 95 98
0 33 9 4 12 11 100 100 98 97
0 33 25 11 30 25 100 100 100 96
Code
mcplot(out, var_y = "es", var_x = 1, var_shape = 2)

Code
ggsave(filename = "figure-trend-length-tau.png", width = 18, height = 18,  device='png', units = "cm", dpi=300, scale = 1.1)
Code
mctable(out, var_y = "es", wider = "statistic", format = "html")
statistic 0
statistic 1
trend_effect length Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted
-0.50 9 -0.27 -0.25 -0.19 -0.19 0.70 0.72 0.30 0.50
-0.25 9 -0.13 -0.12 -0.09 -0.09 0.79 0.79 0.36 0.56
0.00 9 0.00 0.00 0.00 0.00 0.84 0.84 0.42 0.59
0.25 9 0.15 0.14 0.10 0.11 0.88 0.88 0.47 0.63
0.50 9 0.27 0.25 0.19 0.19 0.92 0.91 0.51 0.65
-0.50 12 -0.27 -0.26 -0.19 -0.16 0.71 0.72 0.29 0.48
-0.25 12 -0.14 -0.13 -0.09 -0.08 0.78 0.79 0.35 0.52
0.00 12 0.00 0.00 0.00 0.00 0.84 0.84 0.40 0.55
0.25 12 0.14 0.13 0.09 0.08 0.89 0.88 0.46 0.58
0.50 12 0.27 0.25 0.18 0.16 0.92 0.90 0.50 0.59
-0.50 15 -0.27 -0.26 -0.18 -0.18 0.70 0.71 0.28 0.48
-0.25 15 -0.14 -0.13 -0.09 -0.09 0.78 0.78 0.34 0.53
0.00 15 0.01 0.01 0.01 0.00 0.85 0.85 0.41 0.58
0.25 15 0.13 0.12 0.09 0.09 0.89 0.88 0.45 0.60
0.50 15 0.27 0.26 0.18 0.18 0.91 0.90 0.49 0.62
-0.50 21 -0.27 -0.25 -0.17 -0.17 0.70 0.72 0.28 0.48
-0.25 21 -0.14 -0.13 -0.09 -0.09 0.78 0.79 0.34 0.53
0.00 21 0.00 0.00 0.00 0.00 0.84 0.84 0.39 0.56
0.25 21 0.15 0.14 0.09 0.10 0.89 0.88 0.44 0.59
0.50 21 0.28 0.26 0.18 0.17 0.92 0.90 0.48 0.61
-0.50 27 -0.27 -0.26 -0.18 -0.16 0.70 0.72 0.27 0.47
-0.25 27 -0.14 -0.13 -0.09 -0.08 0.78 0.79 0.33 0.52
0.00 27 -0.01 -0.01 0.00 0.00 0.84 0.84 0.39 0.56
0.25 27 0.14 0.13 0.09 0.08 0.89 0.88 0.43 0.58
0.50 27 0.27 0.25 0.18 0.16 0.92 0.90 0.47 0.59
-0.50 33 -0.27 -0.25 -0.17 -0.16 0.71 0.72 0.27 0.48
-0.25 33 -0.14 -0.13 -0.09 -0.08 0.78 0.79 0.33 0.52
0.00 33 0.00 0.00 0.00 0.00 0.84 0.84 0.39 0.55
0.25 33 0.14 0.13 0.09 0.08 0.89 0.88 0.43 0.58
0.50 33 0.28 0.26 0.18 0.16 0.92 0.90 0.47 0.59

Strength of trend effect and meassurement times (equal phase length)

Code
design <- design_template(
    n = n_sims,
    start_value = 50,
    s = 10,
    level = level_effect * statistic,
    trend = trend_effect / length,
    slope = rnorm(n_sims, 0, 0.1 / (length * 2/3)),
    phase_design = list(A = length * 1/2, B = length * 1/2),
    distribution = "gaussian"
)

iterations <- list(
  trend_effect = c(-0.5, -0.25, 0, +0.25, +0.5),
  length = c(8, 12, 16, 22, 28, 34),
  statistic = c(0,1),
  level_effect = 1,
  n_sims = 5000
)

out <- create_mc("trend-length-2.rds", 
                 design, iterations,
                 force_renew = FALSE)
Code
mcplot(out, var_x = 1, var_shape = 2, template = "power")

Code
ggsave(filename = "figure-trend-length-2.png", width = 18, height = 18,  device='png', units = "cm", dpi=300, scale = 1.1)
Code
mctable(out, var_y = "p", wider = "statistic", format = "html", digits = 0)
statistic 0
statistic 1
trend_effect length Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted
0 8 1 0 1 5 42 31 30 46
0 8 1 1 1 5 54 36 35 55
0 8 3 2 3 5 65 40 40 64
0 8 6 4 5 8 74 41 45 72
0 8 10 5 8 11 82 41 49 79
0 12 0 0 0 4 57 49 38 59
0 12 1 1 1 4 71 58 49 71
0 12 2 2 2 5 83 64 57 81
0 12 6 4 5 7 90 68 64 87
0 12 9 6 8 10 95 70 68 91
0 16 0 0 0 5 75 66 57 76
0 16 1 1 1 5 87 75 68 87
0 16 3 2 3 6 95 83 79 92
0 16 6 4 6 8 98 87 85 94
0 16 14 7 11 14 99 89 89 94
0 22 0 0 0 4 88 83 72 88
0 22 1 1 1 3 96 90 84 95
0 22 3 2 3 4 99 94 91 97
0 22 8 4 6 9 100 97 95 97
0 22 19 10 15 19 100 98 98 96
0 28 0 0 0 5 96 91 85 95
0 28 0 0 1 4 99 96 92 98
0 28 2 2 3 5 100 98 97 97
0 28 9 5 9 10 100 99 99 97
0 28 23 11 18 22 100 100 100 96
0 34 0 0 0 7 98 97 92 98
0 34 0 0 1 5 100 99 97 98
0 34 2 2 3 5 100 100 99 98
0 34 11 6 9 12 100 100 100 97
0 34 27 14 22 26 100 100 100 95
Code
mcplot(out, var_y = "es", var_x = 1, var_shape = 2)

Code
ggsave(filename = "figure-trend-length-2-tau.png", width = 18, height = 18,  device='png', units = "cm", dpi=300, scale = 1.1)
Code
mctable(out, var_y = "es", wider = "statistic", format = "html")
statistic 0
statistic 1
trend_effect length Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted Tau-U A vs. B Tau-U - trendA Tau-U - trendA + trendB Tau-U adjusted
-0.50 8 -0.28 -0.23 -0.16 -0.17 0.70 0.74 0.40 0.52
-0.25 8 -0.14 -0.12 -0.08 -0.08 0.78 0.80 0.45 0.57
0.00 8 0.00 0.00 0.00 0.00 0.84 0.84 0.48 0.60
0.25 8 0.15 0.12 0.08 0.10 0.88 0.86 0.50 0.63
0.50 8 0.28 0.23 0.16 0.17 0.92 0.87 0.52 0.65
-0.50 12 -0.28 -0.23 -0.15 -0.17 0.70 0.74 0.38 0.52
-0.25 12 -0.13 -0.11 -0.08 -0.08 0.78 0.80 0.43 0.57
0.00 12 0.00 0.00 0.00 0.00 0.84 0.84 0.46 0.60
0.25 12 0.15 0.12 0.08 0.09 0.89 0.86 0.48 0.63
0.50 12 0.27 0.23 0.15 0.17 0.92 0.87 0.50 0.64
-0.50 16 -0.28 -0.23 -0.15 -0.16 0.70 0.75 0.37 0.52
-0.25 16 -0.14 -0.11 -0.07 -0.08 0.78 0.80 0.42 0.56
0.00 16 0.00 0.01 0.00 0.01 0.85 0.85 0.45 0.60
0.25 16 0.14 0.11 0.07 0.08 0.89 0.87 0.47 0.62
0.50 16 0.27 0.22 0.15 0.15 0.92 0.87 0.49 0.63
-0.50 22 -0.27 -0.22 -0.14 -0.16 0.70 0.75 0.37 0.51
-0.25 22 -0.14 -0.11 -0.07 -0.09 0.78 0.80 0.41 0.56
0.00 22 0.00 0.00 0.00 0.00 0.84 0.84 0.44 0.59
0.25 22 0.14 0.11 0.07 0.08 0.89 0.86 0.46 0.63
0.50 22 0.27 0.23 0.14 0.16 0.92 0.87 0.48 0.64
-0.50 28 -0.27 -0.23 -0.14 -0.16 0.71 0.75 0.37 0.52
-0.25 28 -0.14 -0.12 -0.07 -0.08 0.78 0.80 0.40 0.56
0.00 28 0.00 0.00 0.00 0.00 0.84 0.84 0.43 0.59
0.25 28 0.14 0.11 0.07 0.08 0.89 0.86 0.46 0.62
0.50 28 0.27 0.22 0.14 0.15 0.92 0.88 0.48 0.63
-0.50 34 -0.27 -0.23 -0.14 -0.15 0.71 0.75 0.36 0.52
-0.25 34 -0.14 -0.12 -0.07 -0.08 0.78 0.81 0.40 0.56
0.00 34 0.00 0.00 0.00 0.00 0.84 0.84 0.43 0.59
0.25 34 0.14 0.12 0.07 0.08 0.89 0.86 0.46 0.61
0.50 34 0.27 0.23 0.14 0.14 0.92 0.87 0.47 0.62